<?php

namespace app\admin\model\tongcheng;

use addons\tongcheng\model\BaseModel;


class DeliveryOrderFeeModel extends BaseModel
{
    // 表名
    protected $name = 'tongcheng_delivery_order_fee';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        // 'status_desc',
        // 'status_buttons',
    ];

    public function getAmountDetailAttr($value, $data)
    {
        return json_decode($value, true) ?: [];
    }

    public function getDiscountsDetailAttr($value, $data)
    {
        return json_decode($value, true) ?: [];
    }

    public function order()
    {
        return $this->belongsTo('app\admin\model\tongcheng\delivery\Order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function couponRecord()
    {
        return $this->belongsTo(CouponRecordModel::class, 'coupon_record_id');
    }
}
